package com.stylefeng.guns.common.constant.enums;

/**
 * 图片类型
 *
 * @author zhfish
 */
public enum ImageType {
    BAN(0, "首页轮播"),
    ADV(1, "广告页");

    int code;
    String message;

    ImageType(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static String valueOf(Integer status) {
        if (status == null) {
            return "";
        } else {
            for (ImageType s : ImageType.values()) {
                if (s.getCode() == status) {
                    return s.getMessage();
                }
            }
            return "";
        }
    }

    public static Integer codeOf(String name) {
        if (name == null) {
            return null;
        } else {
            for (ImageType s : ImageType.values()) {
                if (s.getMessage().equals(name)) {
                    return s.getCode();
                }
            }
            return null;
        }
    }
}
